﻿using System.Text.RegularExpressions;
using System.Runtime.Serialization;

namespace WebApplication1
{
    [DataContract]
    public class GoogleSearchResult : IGdiStoryData
    {
        const string THUMBNAIL_URL = "http://image.picoshot.com/thumbnail.php?url=";
        const string HTML_TAG_PATTERN = "<.*?>";
        string _content;

        [DataMember]
        public string UnescapedUrl { get; set; }
        [DataMember]
        public string Url { get; set; }
        [DataMember]
        public string VisibleUrl { get; set; }
        [DataMember]
        public string TitleNoFormatting { get; set; }
        [DataMember]
        public string Content { get { return stripHTML(_content); } set { _content = value; } }
        [DataMember]
        public string ImageUrl { get { return THUMBNAIL_URL + Url; } private set { } }              

        static string stripHTML(string inputString)
        {
            return Regex.Replace
              (inputString, HTML_TAG_PATTERN, string.Empty);
        }
    }
}
